<template>
  <div id="limitSetup">
    <h1>上下限设定</h1>
    <!--TODO 日期在表单提交的时候写出，不在这里进行勾选-->
    <el-form ref="form_limit" :model="form_limit" label-width="100px">
      <el-form-item label="品度上限">
        <el-input v-model="form_limit.pinduUlim" style="width:100%"></el-input>
      </el-form-item>
      <el-form-item label="品度下限">
        <el-input v-model="form_limit.pinduDlim" style="width:100%"></el-input>
      </el-form-item>
      <el-form-item label="粒度上限">
        <el-input v-model="form_limit.liduUlim" style="width:100%"></el-input>
      </el-form-item>
      <el-form-item label="粒度下限">
        <el-input v-model="form_limit.liduDlim" style="width:100%"></el-input>
      </el-form-item>
      <el-form-item label="水分上限">
        <el-input v-model="form_limit.shuifenUlim" style="width:100%"></el-input>
      </el-form-item>
      <el-form-item label="水分下限">
        <el-input v-model="form_limit.shuifenDlim" style="width:100%"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit('form_limit')">设定上下限</el-button>
        <el-button>取消设定</el-button>
      </el-form-item>
    </el-form>


  </div>
</template>

<script>
export default {
  data() {
    return {
      form_limit: {
        pinduUlim:'',
        pinduDlim:'',
        liduUlim:'',
        liduDlim:'',
        shuifenUlim:'',
        shuifenDlim:''
      }
    }
  },
  methods: {
    onSubmit(formName) {
      console.log('submit!');
      const _this = this
      this.$refs[formName].validate((valid) => {
        if (valid) {
          axios.post('http://localhost:8181/admins/save',this.ruleForm).then(function(resp){
            console.log(resp)
            if(resp.data=='success'){
              _this.$alert("《"+_this.ruleForm.admin_name+"》添加成功！", '添加成功', {
                confirmButtonText: '确定',
                callback: action => {
                  _this.$router.push('/PageOne')
                }
              });
            }
          })
        }
      });
    }
  }
}
</script>

<style>

.el-form-item__label{
  font-family: 思源宋体;
  font-size: medium;
}
.el-input__inner{
  width:20%;
}

h1{
  font-family: 思源宋体;
  font-size: x-large;
}
</style>